﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Cloud.Boss.Models;
using Cloud.Framework.Filter;
using Microsoft.Extensions.Caching.Distributed;
using Cloud.Service.Account;
using Cloud.Service.User;
using Cloud.Service.Log;

namespace Cloud.Boss.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogService _logService;

        public HomeController(ILogService _logService)
        {
            this._logService = _logService;
        }
        [PublicAction]
        [NoLogAction]
        public string Index()
        {

            //RedisHelper.Set("net", "core");

            //var data = RedisHelper.Get("net");

           _logService.WriteRequestLog(new Dto.RequestLogDto()
            {
                ActionName = "index",
                IpAddress = "127.0.0.1",
                ControllerName = "home",
                CreateTime = DateTime.Now,
                HttpStatusCode = 200,
                LoginId = 1,
                LoginName = "admin",
                Method = "get",
                SystemName = "ce"

            });

            return "ok";
        }

        public IActionResult About()
        {
            ViewData["Message"] = "Your application description page.";

            return View();
        }

        public IActionResult Contact()
        {
            ViewData["Message"] = "Your contact page.";

            return View();
        }

        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
